package com.mediacloud.app.newsmodule.fragment.recommend;


import android.content.Context;

import androidx.annotation.NonNull;

import com.eventTrack.CDPTrackReportManager;
import com.mediacloud.app.assembly.interfaces.LoadNetworkBack;
import com.mediacloud.app.assembly.util.Utility;
import com.mediacloud.app.model.component.ComponentItem;
import com.mediacloud.app.model.news.ArticleItem;
import com.mediacloud.app.model.news.ArticleListData;
import com.mediacloud.app.model.news.CatalogItem;
import com.mediacloud.app.model.news.Spider;
import com.mediacloud.app.newsmodule.R;
import com.mediacloud.app.newsmodule.adaptor.component.CDPRecommend;
import com.mediacloud.app.newsmodule.adaptor.component.ComponentListViewX;
import com.mediacloud.app.newsmodule.adaptor.component.RecommendCallBack;
import com.mediacloud.app.newsmodule.fragment.baoliao.api.SpiderCmsLowApi;
import com.mediacloud.app.newsmodule.utils.NotifyEvent;
import com.mediacloud.app.quanzi.model.BaseDataListBean;
import com.mediacloud.app.quanzi.model.DongTaiBean;
import com.mediacloud.app.reslib.util.DataInvokeUtil;
import com.mediacloud.app.user.model.UserInfo;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * 安徽智能推荐相关新闻
 */

public class ComponentRecommendRelatedView extends BaseComponentRelatedView {

    private ComponentListViewX container;
    private List<ArticleItem> listData;
    CatalogItem cat = new CatalogItem();

    public ComponentRecommendRelatedView(Context context) {
        super(context);

    }


    @Override
    public void setData(ArticleItem articleItem,String article_id, ComponentItem component, int type) {
       // super.setData(articleItem,article_id, component, type);
        this.componentItem = component;
        componentItem.setText_align(1);
        header.setComponent(componentItem);
        this.article_id = article_id;
        this.componentId = component.getId() + "";
        componentItem = component;
        //this.type = type;
        CDPRecommend.getInstance().getRecommendData(getContext(), data -> {
            if (data.isEmpty()) {
                return;
            }
            mRootView.setVisibility(VISIBLE);
            setVisibility(VISIBLE);

            listData = data;
            container.setData(data, cat,component.getTitle());
            for (int i = 0; i < data.size(); i++) {
                CDPTrackReportManager.getInstance().NewsRPExpose(i,data.get(i),component.getTitle());
            }

        },component.page,article_id);

    }


    @Override
    public int setLayoutRes() {
        return R.layout.component_related_recommendation_new;
    }

    @Override
    public void initOtherViews() {
        container = Utility.findViewById(mRootView, R.id.container);
        container.setDetailComponentList(true);
    }

    @Override
    public void onDataSuccess(ArticleListData data) {

    }

    @Override
    public void onDataFault(Object data) {

    }


}